package com.geekaca.iobuffer;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class HelloFileReader1 {
    public static void main(String[] args) {

        try (
            Reader fileReader = new FileReader("studyIOBuffer/test.txt");
        ) {
            //只读取一个字符
//            int read = fileReader.read();
//            System.out.println((char) read);

            int len = -1;
            char[] charArr = new char[16];
            while ((len = fileReader.read(charArr)) != -1) {
                System.out.println(new String(charArr, 0, len));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
